package com.slz3.business.module.wmsManagement.wmsTraysManage.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.wmsManagement.wmsTraysManage.domain.WmsTraysManage;
import com.slz3.business.module.wmsManagement.wmsTraysManage.domain.WmsTraysManageFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class WmsTraysManageTransactionalServiceImpl implements WmsTraysManageTransactionalService {

    @Override
    public WmsTraysManage modify(WmsTraysManage wmsTraysManageNew) {
        Repositorys.wmsTraysManage.test();
        Repositorys.wmsTraysManage.save(WmsTraysManageFactory.initBaseFields());
        System.err.println(1 / 0);
        wmsTraysManageNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.wmsTraysManage.saveAndFlush(wmsTraysManageNew);
    }

    @Override
    public List<WmsTraysManage> batchSave(List<WmsTraysManage> wmsTraysManages) {
        wmsTraysManages.forEach(WmsTraysManageFactory::initBaseFields);
        return Repositorys.wmsTraysManage.saveAll(wmsTraysManages);
    }

    @Override
    public List<WmsTraysManage> batchModify(List<WmsTraysManage> wmsTraysManageList) {
        return Repositorys.wmsTraysManage.saveAll(wmsTraysManageList);
    }
}
